package com.itqf.anno;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/10/9
 * @Time: 上午10:07
 */
@Aspect   //基于注解的配置
@Component
//@Repository
//@Service
//@Controller
public class MyAdvice {

    @Pointcut("execution(* com.itqf.anno.service.impl.*.*(..))")
    public void  myPointcut(){

    }

    @Around("myPointcut()")
   // @Around("execution(* com.itqf.anno.service.impl.*.*(..))")
    public void  arount(ProceedingJoinPoint proceedingJoinPoint){
        System.out.println("arount前"+proceedingJoinPoint.getTarget().getClass());
        //日志
        try {
            //得到目标方法的参数列表
            Object params [] = proceedingJoinPoint.getArgs();

            Object result = proceedingJoinPoint.proceed(params);
            System.out.println("result"+result);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }

        System.out.println("arount后"+proceedingJoinPoint.getTarget().getClass());


    }

}
